package com.autumn.sms.service;

import com.autumn.util.ApplicationException;

/**
 * 短信发送异常
 * 
 * @author 老码农
 *
 *         2018-01-13 12:23:04
 */
public class SmsSendException extends ApplicationException {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6413674987459573897L;

	private static final int SMS_SEND_ERROR_CODE = ApplicationErrorCode.APPLICATION_ERRORCODE + 2300;
	
	
	private final boolean isRepeatSend;
	private final boolean isSupportRepeatSend;

	/**
	 * 无构造实例化
	 */
	public SmsSendException() {
		this(false, false, "发送短信出错", null);
	}

	/**
	 * 实例化
	 * 
	 * @param isSupportRepeatSend
	 *            是否支持重复发送
	 * @param isRepeatSend
	 *            是否重复发送
	 * @param message
	 *            消息
	 */
	public SmsSendException(boolean isSupportRepeatSend, boolean isRepeatSend, String message) {
		this(isSupportRepeatSend, isRepeatSend, message, null);
	}

	/**
	 * 
	 * @param isSupportRepeatSend
	 *            是否支持重复发送
	 * @param isRepeatSend
	 *            是否重复发送
	 * @param message
	 *            消息
	 * @param cause
	 *            源异常
	 */
	public SmsSendException(boolean isSupportRepeatSend, boolean isRepeatSend, String message, Throwable cause) {
		super(message, cause);
		this.setCode(SMS_SEND_ERROR_CODE);
		this.isSupportRepeatSend = isSupportRepeatSend;
		this.isRepeatSend = isRepeatSend && isSupportRepeatSend;
	}

	/**
	 * 是否重复发送
	 * 
	 * @return
	 *
	 */
	public boolean isRepeatSend() {
		return isRepeatSend;
	}

	/**
	 * 是否支持重复发送
	 * 
	 * @return
	 *
	 */
	public boolean isSupportRepeatSend() {
		return isSupportRepeatSend;
	}

}
